<?php

class RatesController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		//
        $service_id = Input::get('id');
        $service = Service::find($service_id);
        if($service->customer_id != Input::get('customer_id')){
            echo '无权评价';
            exit;
        }
        $customer = Customer::find(Input::get('customer_id'));
        return View::make('rates.index',compact('service','customer'));
	}


	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//

	}


	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
        $service = Service::find(Input::get('id'));
        $rate = new Rate();
        $rate->service_id = Input::get('id');
        $rate->form1 = Input::get('form1');
        $rate->form2 = Input::get('form2');
        $rate->form3 = Input::get('form3');
        $rate->work_id = $service->worker_id;
        $rate->customer_id = $service->customer_id;
        $rate->city = Input::get('city');
        $rate->area = Input::get('area');
        $rate->remark = Input::get('remark');
        $rate->machine_id = $service->mount->machine_id;
        $rate->save();
        $service->rate_id = $rate->id;
        $service->save();
	}


	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//

//        var_dump($rates);
	}


	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}


	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}


	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//


	}



}
